package com.imooc.ecommerce.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * <p>消息传递对象: SpringCloud Stream + Kafka/RocketMQ
 *
 * @author Yaxi.Zhang
 * @since 2022/11/15 19:22
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class QinyiMessage {

    private Integer id;
    private String projectName;
    private String org;
    private String author;
    private String version;

    private static final AtomicInteger ai = new AtomicInteger(0);

    /**
     * <p>返回一个默认的消息, 方便使用
     */
    public static QinyiMessage defaultMessage() {
        Integer count = ai.incrementAndGet();
        return new QinyiMessage(count, "e-commerce-stream-client" + count, "imooc.com", "Qinyi", count + ".0");
    }

}
